
<!DOCTYPE html>
<html lang="zh">



<head>
  <script>
    window.themeRuntime = {
      root: "/",
      scriptsMap: {},
      init: {
        status: false
      },
      commentRest: {
        status: false
      },
      versions: {
        theme: "2.0.3",
        mdui: "0.4.0",
        fetch: "3.0.0",
        es6promise: "4.2.5+7f2b526d",
        lightgallery: "1.0.1",
        smoothscroll: "15.2.0"
      }
      
    };
    console.info("%cCopyright © 2018 - " + new Date().getFullYear() +" Halyul\n"+'Theme Version: ' + themeRuntime.versions.theme +'%c\nhttps://github.com/Halyul/hexo-theme-mdui',"font-size: 14px;color: #3F51B5;","color: #448AFF;text-decoration: none");
  </script>
  <!--
        © HEXO MDUI Theme
        https://github.com/Halyul/hexo-theme-mdui
        -->

  <meta charset="UTF-8">
  <title>UVa1585 Score 题解 - Kozumi Blog</title>

  <!-- Favicons -->
  <link rel="icon shortcut" type="image/ico" href="/images/favicon.png">
  <link rel="icon" sizes="192x192" href="/images/favicon.png">
  <link rel="apple-touch-icon" href="/images/favicon.png">

  <!-- Meta & Info -->
  <meta http-equiv="X-UA-Compatible">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

  <meta name="theme-color" content="#fff">

  <meta name="author" content="Kozumi">
  
  <meta name="keywords" content="blog, hexo, mdui">

  <!--iOS -->
  <meta name="apple-mobile-web-app-title" content="Kozumi Blog">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="480">

  <!-- Add to homescreen for Chrome on Android -->
  <meta name="mobile-web-app-capable" content="yes">

  <!-- The Open Graph protocol -->
  <meta property="og:url" content="https://xuyang1638.github.io">
  <meta property="og:type" content="blog">
  <meta property="og:title" content="UVa1585 Score 题解 - Kozumi Blog | Kozumi Blog">
  <meta property="og:image" content="/images/favicon.png" />
  

  

  

  <!-- Import CSS -->
  
    
<link rel="stylesheet" href="/css/mdui.css">

  

  

<meta name="generator" content="Hexo 4.2.0"></head>


<body class="mdui-drawer-body-left mdui-theme-primary-indigo mdui-theme-accent-pink">

  <style>
    #spinner {
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
      -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
          opacity: 1;
      -webkit-transition: opacity 0.3s cubic-bezier(0, 0, 0.2, 1);
          transition: opacity 0.3s cubic-bezier(0, 0, 0.2, 1);
    }
    main {
      opacity: 0;
      -webkit-transition: opacity 0.3s cubic-bezier(0, 0, 0.2, 1);
      transition: opacity 0.3s cubic-bezier(0, 0, 0.2, 1);
      display: none;
    }
  </style>
  <div id="spinner">
    <style>
      .spinner {

      -webkit-animation: rotator 1.4s linear infinite;
              animation: rotator 1.4s linear infinite;
      }

      @-webkit-keyframes rotator {
      0% {
        -webkit-transform: rotate(0deg);
                transform: rotate(0deg);
      }
      100% {
        -webkit-transform: rotate(270deg);
                transform: rotate(270deg);
      }
      }

      @keyframes rotator {
      0% {
        -webkit-transform: rotate(0deg);
                transform: rotate(0deg);
      }
      100% {
        -webkit-transform: rotate(270deg);
                transform: rotate(270deg);
      }
      }

      .path {
      stroke-dasharray: 187;
      stroke-dashoffset: 0;
      -webkit-transform-origin: center;
              transform-origin: center;
      -webkit-animation: dash 1.4s ease-in-out infinite, colors 5.6s ease-in-out infinite;
              animation: dash 1.4s ease-in-out infinite, colors 5.6s ease-in-out infinite;
      }

      @-webkit-keyframes colors {
      0% {
        stroke: #4285F4;
      }
      25% {
        stroke: #DE3E35;
      }
      50% {
        stroke: #F7C223;
      }
      75% {
        stroke: #1B9A59;
      }
      100% {
        stroke: #4285F4;
      }
      }

      @keyframes colors {
      0% {
        stroke: #4285F4;
      }
      25% {
        stroke: #DE3E35;
      }
      50% {
        stroke: #F7C223;
      }
      75% {
        stroke: #1B9A59;
      }
      100% {
        stroke: #4285F4;
      }
      }

      @-webkit-keyframes dash {
      0% {
        stroke-dashoffset: 187;
      }
      50% {
        stroke-dashoffset: 46.75;
        -webkit-transform: rotate(135deg);
                transform: rotate(135deg);
      }
      100% {
        stroke-dashoffset: 187;
        -webkit-transform: rotate(450deg);
                transform: rotate(450deg);
      }
      }

      @keyframes dash {
      0% {
        stroke-dashoffset: 187;
      }
      50% {
        stroke-dashoffset: 46.75;
        -webkit-transform: rotate(135deg);
                transform: rotate(135deg);
      }
      100% {
        stroke-dashoffset: 187;
        -webkit-transform: rotate(450deg);
                transform: rotate(450deg);
      }
      }
    </style>
    <svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
      <circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
    </svg>
  </div>

  <main>
    <div class="mdui-appbar mdui-appbar-fixed mdui-color-white mdui-shadow-0 theme-appbar">
  <div class="mdui-toolbar theme-toolbar-top">
    
      <a href="/" class="mdui-btn mdui-btn-icon mdui-ripple theme-appbar__burger theme-appbar__burger--arrow">
        <i class="mdui-icon">
          <span></span>
        </i>
      </a>
    
  </div>
  <div class="mdui-toolbar theme-toolbar-bottom">
    <span class="theme-toolbar-bottom__title">Kozumi Blog</span>
    
      <a href="/search.html" class="mdui-textfield-icon mdui-btn mdui-btn-icon theme-toolbar-bottom__search">
        <i class="mdui-icon material-icons">&#xe8b6;</i>
      </a>
    
  </div>
  <div class="mdui-progress theme-appbar__progress" id="progressBar">
    <div class="mdui-progress-indeterminate"></div>
  </div>
</div>

    <div class="mdui-drawer mdui-drawer-full-height theme-drawer" id="drawer">
  <!-- header -->
  <div class="theme-drawer__header">
  <div class="theme-drawer__header__layer-1">
    <div class="mdui-toolbar theme-toolbar-top">
      
        <a href="javascript:;" class="mdui-btn mdui-btn-icon mdui-ripple theme-appbar__burger theme-appbar__burger--drawer theme-appbar__burger--arrow" id="drawer-back">
          <i class="mdui-icon">
            <span></span>
          </i>
        </a>
      
    </div>
    <div class="mdui-toolbar theme-toolbar-bottom">
      <span class="theme-toolbar-bottom__title">Kozumi Blog</span>
    </div>
  </div>
  <div class="theme-drawer__header__layer-2" style="background-image: url(/images/bg.png)">
    <img class="mdui-img-circle theme-drawer__header__layer-2__user__avatar" src="/images/avatar.png"/>
    <div class="theme-drawer__header__layer-2__user__info">
      <div class="theme-drawer__header__layer-2__user__info__author mdui-text-color-white-text">
        Kozumi
      </div>
      <div class="theme-drawer__header__layer-2__user__info__slogan mdui-text-color-white-secondary">
        Do the best
      </div>
    </div>
  </div>
</div>

  <div class="theme-drawer__warpper">
    <!-- content -->
    <div class="theme-drawer__warpper__content">
  <ul class="mdui-list">
    <a href="/" class="mdui-list-item mdui-ripple mdui-ripple-white">
      <i class="mdui-list-item-icon mdui-icon material-icons">&#xe88a;</i>
      <div class="mdui-list-item-content">Index</div>
    </a>
    <a href="/archives/" class="mdui-list-item mdui-ripple mdui-ripple-white">
      <i class="mdui-list-item-icon mdui-icon material-icons">&#xe149;</i>
      <div class="mdui-list-item-content">Archives</div>
    </a>
    <ul class="mdui-list mdui-collapse" mdui-collapse="{accordion: true}" mdui-collapse>
      
      
      <div class="mdui-collapse-item ">
        <div class="mdui-collapse-item-header mdui-list-item mdui-ripple mdui-ripple-white">
          <i class="mdui-list-item-icon mdui-icon material-icons">&#xe916;</i>
          <div class="mdui-list-item-content">Years</div>
          <i class="mdui-collapse-item-arrow mdui-icon material-icons">&#xe5c5;</i>
        </div>
        <div class="mdui-collapse-item-body mdui-list">
          
          
            <a href="/archives/2020/" class="mdui-list-item mdui-ripple">
              2020
            </a>
          
        </div>
      </div>
    </ul>
  </ul>
  
    <div class="mdui-divider"></div>
    <ul class="mdui-list" mdui-collapse="{accordion: true}" mdui-collapse>
      
        
          
            <a href="/myfriends" target="_self" class="mdui-list-item mdui-ripple mdui-ripple-white">
          
              
              
                <i class="mdui-list-item-icon mdui-icon material-icons">&#xe5ca;</i>
              
              
              <div class="mdui-list-item-content">My Friends</div>
            </a>
        
      
        
          
            <a href="/timeline" target="_self" class="mdui-list-item mdui-ripple mdui-ripple-white">
          
              
              
                <i class="mdui-list-item-icon mdui-icon material-icons">home</i>
              
              
              <div class="mdui-list-item-content">Timeline</div>
            </a>
        
      
    </ul>
  
</div>

    <div class="theme-spacer"></div>
    <!-- footer -->
    <div class="theme-drawer__warpper__footer">
  <div class="mdui-typo mdui-typo-caption-opacity">
    Powered by <a href="http://hexo.io" target="_blank">Hexo</a>
    <br />
    Theme - <a href="//github.com/Halyul/hexo-theme-mdui" target="_blank">Halyul/MDUI</a>
    <br />
    <span>
      Copyright ©
      <span year></span>
      Kozumi
    </span>
    
    
      <br />
      <span>
        Last Updated: Apr 19, 2020
      </span>
    
    
  </div>
</div>
<script type="text/javascript">
  var copyrightNow = new Date().getFullYear();
  var textContent = document.querySelector('span[year]')
  
    copyrightSince = 2020;
    if (copyrightSince === copyrightNow) {
      textContent.textContent = copyrightNow
    } else {
      textContent.textContent = copyrightSince + ' - ' + copyrightNow
    }
  
</script>

  </div>
</div>

    <div id="top"></div>

    
<script src="/js/lightgallery.min.js"></script>


    <div id="barba-wrapper">
      <div class="barba-container"  data-namespace="post">
        



  
<link rel="stylesheet" href="/css/prism/darcula.min.css">



  
<link rel="stylesheet" href="/css/prism/line-number.min.css">



<div class="theme-post">
  <div class="theme-post__background mdui-color-theme"></div>
  <div class="theme-post__header mdui-color-theme">
    <div class="theme-post__header__title mdui-text-truncate">
      UVa1585 Score 题解
    </div>
    <div class="theme-spacer"></div>
    <div class="theme-post__header__actions mdui-valign">
      <div>
        <span>Posted: </span>
        <span style="float: right">Mar 31, 2020</span>
        
        <br>
          <span>Last Modified: </span>
          <span>Apr 19, 2020</span>
        
      </div>
      
  <div class="theme-post__qrcode">
  </div>


      
  <div class="theme-post__share">
    <button class="mdui-btn mdui-ripple mdui-btn-icon" mdui-menu="{target: '#post-share-menu'}">
      <i class="mdui-icon material-icons">&#xe80d;</i>
    </button>

    <ul class="mdui-menu" id="post-share-menu">

      
        <li class="mdui-menu-item">
            <a href="https://www.facebook.com/sharer/sharer.php?u=https://xuyang1638.github.io//2020/03/31/UVa1585%20Score%20%E9%A2%98%E8%A7%A3/index.html" target="_blank" class="mdui-ripple">
                Share to Facebook
            </a>
        </li>
      

      
        <li class="mdui-menu-item">
            <a href="https://plus.google.com/share?url=https://xuyang1638.github.io//2020/03/31/UVa1585%20Score%20%E9%A2%98%E8%A7%A3/index.html" target="_blank" class="mdui-ripple">
                Share to Google+
            </a>
        </li>
      

      
        <li class="mdui-menu-item">
            <a href="https://www.linkedin.com/shareArticle?mini=true&url=https://xuyang1638.github.io//2020/03/31/UVa1585%20Score%20%E9%A2%98%E8%A7%A3/index.html&title=UVa1585 Score 题解" target="_blank" class="mdui-ripple">
                Share to Linkedin
            </a>
        </li>
      

      

      

      
        <li class="mdui-menu-item">
            <a href="https://twitter.com/intent/tweet?text=UVa1585 Score 题解&url=https://xuyang1638.github.io//2020/03/31/UVa1585%20Score%20%E9%A2%98%E8%A7%A3/index.html&via=Kozumi" target="_blank" class="mdui-ripple">
                Share to Twitter
            </a>
        </li>
      

      

    </ul>
  </div>


    </div>
  </div>
  <div class="theme-post__warpper
    
      theme-post__warpper--center
    
  ">
    <div class="theme-post__warpper__container">
      <article class="mdui-card theme-post__card mdui-hoverable">
        <section class="theme-post__card__warning">
          This article was last modified
          <span id="content-warning"></span>
          days ago.
          The content of this post may be outdated!
        </section>
        
        
          <section class="mdui-card-media">
            <img src="/images/random/39.png"/>
          </section>
        
        <section class="mdui-typo theme-post__card__content">
          <p><a href="https://onlinejudge.org/external/15/1585.pdf" target="_blank" rel="noopener">UVa1585 题目原地址</a></p>
<p>本体思路重点在于分数的统计及重置。<br>由题面可得输入的是一个小于80个字符的字符串，故使用一个字符数组存储。</p>
<p>更新 2020/3/1 11:52<br>傻了，uva评测太慢代码挂上就先去摸鱼，结果一看wa了。看了下代码，只写了主功能函数。给定的输入有多个kase…<br>代码更新如下（ifdef内的是调试代码，可去掉）：</p>
<pre class="line-numbers language-cpp" mdui-tooltip="{content: 'cpp'}"><code class="language-cpp"><span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">&lt;cstdlib></span></span>

<span class="token keyword">int</span> <span class="token function">getScore</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
 <span class="token keyword">int</span> quantity <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
 <span class="token keyword">int</span> score <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
 <span class="token keyword">char</span> inputs<span class="token punctuation">[</span><span class="token number">80</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">;</span>

 <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%s"</span><span class="token punctuation">,</span> inputs<span class="token punctuation">)</span><span class="token punctuation">;</span>
 <span class="token macro property">#<span class="token directive keyword">ifdef</span> DEBUG</span>
 <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Current string: %s\n"</span><span class="token punctuation">,</span> inputs<span class="token punctuation">)</span><span class="token punctuation">;</span>
 <span class="token macro property">#<span class="token directive keyword">endif</span></span>

 <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;=</span> <span class="token number">80</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">'O'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
   quantity<span class="token operator">++</span><span class="token punctuation">;</span>
   score <span class="token operator">+</span><span class="token operator">=</span> quantity<span class="token punctuation">;</span>
   <span class="token macro property">#<span class="token directive keyword">ifdef</span> DEBUG</span>
   <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Current quantity of O: %d\n"</span><span class="token punctuation">,</span> quantity<span class="token punctuation">)</span><span class="token punctuation">;</span>
   <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Score: %d\n\n"</span><span class="token punctuation">,</span> score<span class="token punctuation">)</span><span class="token punctuation">;</span>
   <span class="token macro property">#<span class="token directive keyword">endif</span></span>
  <span class="token punctuation">}</span>
  <span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">'X'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
   quantity <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
   <span class="token macro property">#<span class="token directive keyword">ifdef</span> DEBUG</span>
   <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Current character is X.\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
   <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"Score: %d\n\n"</span><span class="token punctuation">,</span> score<span class="token punctuation">)</span><span class="token punctuation">;</span>
   <span class="token macro property">#<span class="token directive keyword">endif</span></span>
  <span class="token punctuation">}</span>
 <span class="token punctuation">}</span>

 <span class="token keyword">return</span> score<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span><span class="token punctuation">{</span>

 <span class="token macro property">#<span class="token directive keyword">ifdef</span> DEBUG</span>
 <span class="token function">freopen</span><span class="token punctuation">(</span><span class="token string">"data.in"</span><span class="token punctuation">,</span> <span class="token string">"r"</span><span class="token punctuation">,</span> <span class="token constant">stdin</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
 <span class="token macro property">#<span class="token directive keyword">endif</span></span>

 <span class="token keyword">int</span> <span class="token operator">*</span>scores<span class="token punctuation">;</span>

 <span class="token keyword">int</span> kase_quantity <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
 <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%d"</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>kase_quantity<span class="token punctuation">)</span><span class="token punctuation">;</span>
 <span class="token comment" spellcheck="true">// create a array to save scores of each kase</span>
 scores <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">int</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token function">calloc</span><span class="token punctuation">(</span>kase_quantity<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

 <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;=</span> kase_quantity<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">int</span> score <span class="token operator">=</span> <span class="token function">getScore</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  scores<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> score<span class="token punctuation">;</span>
 <span class="token punctuation">}</span>
 <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> kase_quantity<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%d\n"</span><span class="token punctuation">,</span> scores<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
 <span class="token punctuation">}</span>

 <span class="token comment" spellcheck="true">// free memory used by scores array</span>
 <span class="token function">free</span><span class="token punctuation">(</span>scores<span class="token punctuation">)</span><span class="token punctuation">;</span>

 <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<p>废话不多说，代码如下：</p>
<pre class="line-numbers language-cpp" mdui-tooltip="{content: 'cpp'}"><code class="language-cpp"><span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
 <span class="token keyword">char</span> inputs<span class="token punctuation">[</span><span class="token number">80</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
 <span class="token keyword">int</span> quantity <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
 <span class="token keyword">int</span> score<span class="token punctuation">;</span>

 <span class="token function">scanf</span><span class="token punctuation">(</span><span class="token string">"%s"</span><span class="token punctuation">,</span> inputs<span class="token punctuation">)</span><span class="token punctuation">;</span>
 <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;=</span> <span class="token number">80</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">'O'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
   score <span class="token operator">+</span><span class="token operator">=</span> quantity<span class="token punctuation">;</span>
   quantity<span class="token operator">++</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
  <span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">==</span> <span class="token string">'X'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
   quantity <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
 <span class="token punctuation">}</span>

 <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">"%d\n"</span><span class="token punctuation">,</span> score<span class="token punctuation">)</span><span class="token punctuation">;</span>

 <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

        </section>

        
          <section class="theme-post__card__license mdui-typo">
            <span>
              Article License: 
              
                <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" target="_blank">CC BY-NC-SA 4.0</a>
              
            </span>
            <br />
            <span>Article Permalink: <a href="https://xuyang1638.github.io/2020/03/31/UVa1585%20Score%20%E9%A2%98%E8%A7%A3/">https://xuyang1638.github.io/2020/03/31/UVa1585%20Score%20%E9%A2%98%E8%A7%A3/</a></span>
            
              <br />
              <span>Article Markdown: <a href="https://xuyang1638.github.io/2020/03/31/UVa1585%20Score%20%E9%A2%98%E8%A7%A3/UVa1585 Score 题解.md">https://xuyang1638.github.io/2020/03/31/UVa1585%20Score%20%E9%A2%98%E8%A7%A3/UVa1585 Score 题解.md</a></span>
            
          </section>
        

        
          <section class="mdui-card-actions theme-post__card__actions">
            
              <button class="mdui-btn mdui-btn-icon mdui-btn-dense mdui-ripple  mdui-color-red" mdui-tooltip="{content: 'Buy me a beer?', position: 'right'}" mdui-dialog="{target: '#donateDialog'}">
                <i class="mdui-icon fa fa-beer"></i>
              </button>
            
            <div class="theme-spacer"></div>
            
            
          </section>
        

        
          
            <script type="text/javascript">
              themeRuntime.commentRest.function = function (newIdentifier, newUrl, newTitle) {
                return
              }
            </script>
          
        
      </article>
      
    </div>
  </div>

  <div class="theme-spacer"></div>

  

  
    <div class="theme-post__pagination mdui-color-theme">
  
    <div class="theme-post__pagination__prev mdui-ripple mdui-valign">
      <a href="/2020/04/01/Copycat%E9%A2%98%E8%A7%A3/" class="theme-post__pagination__prev__content mdui-text-left">
        <div>
          <i class="mdui-icon material-icons mdui-text-center">&#xe5cb;</i>
          <span class="mdui-typo-body-2-opacity mdui-text-center">Newer Post</span>
        </div>
        <div class="mdui-typo-title mdui-text-truncate">
          LOJ#3 Copycat 题解
        </div>
      </a>
    </div>
  

  
    <div class="theme-post__pagination__next mdui-ripple mdui-valign">
      <a href="/2020/03/12/hello-world/" class="theme-post__pagination__next__content mdui-text-right">
        <div>
          <span class="mdui-typo-body-2-opacity mdui-text-center">Older Post</span>
          <i class="mdui-icon material-icons mdui-text-center">&#xe5cc;</i>
        </div>
        <div class="mdui-typo-title mdui-text-truncate">
          Hello World
        </div>
      </a>
    </div>
    
</div>

  

  
    <div class="mdui-dialog" id="donateDialog">
      <div class="mdui-dialog-title">Buy me a beer?</div>
      <div class="mdui-dialog-content">
        <div class="mdui-list">
          
            <a href="/img/avatar.png" title="wechat" class="mdui-list-item mdui-ripple" target="_blank">
              
                <i class="mdui-list-item-icon mdui-icon fa fa-wechat mdui-text-center"></i>&emsp;
              
              
              
              wechat
            </a>
          
            <a href="https://paypal.com" title="paypay" class="mdui-list-item mdui-ripple" target="_blank">
              
                <i class="mdui-list-item-icon mdui-icon fa fa-paypal mdui-text-center"></i>&emsp;
              
              
              
              paypay
            </a>
          
        </div>
      </div>
      <div class="mdui-dialog-actions">
        <button class="mdui-btn mdui-ripple mdui-ripple" mdui-dialog-close>Cancel</button>
      </div>
    </div>
  
</div>
<script type="text/javascript">
  themeRuntime.scriptsMap.post = [];
  if (document.querySelector('.theme-post__toc-fab__menu > ol') !== null && document.querySelector('.theme-post__toc > ol') !== null) {
    tocHighlight()
    function tocHighlight() {
      var timer;
      function doWork() {
        listens.forEach(function(value, index) {
          value[1]();
          value[0].classList.remove("mdui-list-item-active");
        })
        let actionToc = (listens[listens.reduce(function(r, v, index) {
          if (v[2] == true) {
            return index;
          } else return r;
        }, undefined)] || [])[0] || listens[0][0];
        actionToc.classList.add("mdui-list-item-active");
        if(actionToc.getClientRects().length == 0)return;
        showToc(actionToc);
      }
      function showToc(toc) {
        let offsetTop = toc.getClientRects()[0].top - cardToc.getClientRects()[0].top - 40;
        let offsetBottom = toc.getClientRects()[0].bottom - cardToc.getClientRects()[0].bottom + 40;
        let offset = 0;
        if (offsetTop < 0) offset = offsetTop;
        if (offsetBottom > 0) offset = offsetBottom;
        var targetTop = Math.max(0, Math.min(cardToc.scrollTop + offset, toclist.offsetHeight - cardToc.offsetHeight));
        clearInterval(timer);
        timer = setInterval(function() {
          var now = cardToc.scrollTop;
          var speed = (targetTop - now) / 10;
          speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
          if (Math.abs(now - targetTop) < 1) {
            clearInterval(timer);
          }
          cardToc.scrollTop = now + speed;
        }, 30);
      }
      var listens = [];
      var cardToc = document.querySelector('.theme-post__toc');
      var links = cardToc.querySelectorAll(".theme-post__toc__content__link");
      var toclist = document.querySelector(".theme-post__toc > ol");
      Array.prototype.forEach.call(links, function(value, index) {
        var id = (value.getAttribute("href") || "#").slice(1);
        var element = document.getElementById(id);
        listens.push([value, function() {
          var readed = false;
          var scrollTop = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
          if (element.offsetTop <= scrollTop + element.clientHeight + 64) {
            readed = true;
          } else {
            readed = false;
          }
          listens[index][2] = readed;
        }, false])
      })
      doWork();
      window.addEventListener("scroll", doWork)
      var listener = {
        function:  doWork,
        event: 'scroll',
        el: window,
        removed: false
      }
      themeRuntime.scriptsMap.post.push(listener)
    }
  }
</script>

<script type="text/javascript">
  (function() {
    var postLastModifiedDate = 1587262419188
    var today = (new Date()).getTime()
    var difference = Math.floor((today - postLastModifiedDate)/(24*60*60*1000))
    if (difference >= 100) {
      document.querySelector('.theme-post__card__warning').style.display = 'block'
      document.querySelector('#content-warning').textContent = difference
    }
  })();
</script>

<script type="text/javascript">
  var images = document.querySelectorAll('.theme-post__card__content img')
  for (i = 0; i < images.length; i++) {
    //console.log('image added', i)
    images[i].addEventListener("click", openLG);
    var listener = {
      function:  openLG,
      event: 'click',
      el: images[i],
      removed: false
    }
    themeRuntime.scriptsMap.post.push(listener)
  }
  function openLG() {
    var img_src = this.getAttribute('src');
    var img_alt = this.getAttribute('alt');
    lightGallery(this, {
      dynamic: true,
      counter: false,
      dynamicEl: [{
        "src": img_src,
        'subHtml': "<span author>Kozumi</span><div descr>" + img_alt + "</div>"
      }],
    });
  }
</script>




      </div>
    </div>
  </main>

  <div id="outdated" style="z-index: 9999;">
    <h6>Your browser is out-of-date!</h6>
    <p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/" target="_blank" rel="noopener">Update my browser now </a></p>
    <p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p>
  </div>
  <!-- import js -->


  
<script src="/js/outdatedbrowser.min.js"></script>




  
    
<script src="/js/js.barba.min.js"></script>

    <script type="text/javascript">
      Barba.Utils.errorPageUrl = '/404.html';
    </script>
  


<!-- theme js -->
<script type="text/javascript">
  (function() {
    var appbarTopFlag = false;
    var appbarEl = document.querySelector('.theme-appbar');
    function appbarShadow() {
      var bodyScrolled = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
      if (bodyScrolled > 0 && !appbarTopFlag) {
        appbarEl.classList.add('theme-appbar--shadow');
        appbarTopFlag = true;
      } else if (bodyScrolled === 0 && appbarTopFlag) {
        appbarEl.classList.remove('theme-appbar--shadow');
        appbarTopFlag = false;
      }
    }
    appbarShadow()
    window.addEventListener('scroll', appbarShadow);
  })();
</script>






<script type="text/javascript">
  document.querySelector('body').classList.add('theme-loaded')
</script>




</body>
</html>
